<template>
  <h3>双向绑定指令V-MODEL</h3>
  <!-- 双向绑定:将页面与下方变量info进行绑定
   1)info变量的值会显示在绑定的html元素上
   2)页面html元素发生改变,绑定的info变量的值也会随之改变-->
  <input type="text" placeholder="请输入用户名" v-model="user.username">
  <input type="password" placeholder="请输入密码" v-model="user.password">
  <br>
  性别:
  <input type="radio" name="gender" value="1" v-model="user.gender">男
  <input type="radio" name="gender" value="0" v-model="user.gender">女
  <button @click="f()">获取输入的值</button>
</template>

<script setup>
import {ref} from "vue";
const user = ref({username:'tom',password:'123',gender:"0"})
const f = ()=>{
  console.log(user.value);//代理对象
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.gender);
}
//将局部变量赋值给一个全局对象
//window.user=user;
</script>

<style scoped>

</style>